package main

import "fmt"

func main() {
	var numbers = make([]int, 3, 5)
	//向numbers切片追加一个元素1，numbers len=4，[0,0,0,1] cap=5
	numbers = append(numbers, 1)
	printSlice(numbers)
	//向numbers切片追加一个元素2，numbers len=5，[0,0,0,1,2] cap=5
	numbers = append(numbers, 2)
	printSlice(numbers)

	//向一个容量满了的slice追加元素,cap会*2
	numbers = append(numbers, 3, 4)
	printSlice(numbers)

	numbers1 := make([]int, len(numbers))
	copy(numbers1, numbers)
	printSlice(numbers1)
}

func printSlice(x []int) {
	fmt.Printf("len=%d cap=%d slice=%v\n", len(x), cap(x), x)
}
